package com.rfid.acs.bean;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.Nullable;

public class BookBean implements Parcelable {
    /**
     * uid
     */
    private String tagId;

    /**
     * 图书ID/条码
     */
    private String bookId;

    /**
     * 图书题名
     */
    private String bookName;

    /**
     * 索书号
     */
    private String indexNo;

    /**
     * 图书价格
     */
    private String bookPrice;

    /**
     * 图书类型
     */
    private String bookType;

    /**
     * 图书所属馆藏地
     */
    private String bookFromLocation;

    /**
     * 图书当前馆藏地
     */
    private String bookCurrentLocation;

    /**
     * 图书状态
     */
    private String bookStatus;

    /**
     * 出版社
     */
    private String publisher;

    /**
     * 作者
     */
    private String author;

    /**
     * 借出日期
     */
    private String borrowDate;

    /**
     * 应还日期
     */
    private String limitDate;


    /**
     * 是否逾期，根据查询读者信息返回数据算出
     */
    private boolean overdue;

    /**
     * 是否借成功
     */
    private boolean success = true;

    private String hintMessage;

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getBookId() {
        return bookId;
    }

    public void setBookId(String bookId) {
        this.bookId = bookId;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getIndexNo() {
        return indexNo;
    }

    public void setIndexNo(String indexNo) {
        this.indexNo = indexNo;
    }

    public String getBookPrice() {
        return bookPrice;
    }

    public void setBookPrice(String bookPrice) {
        this.bookPrice = bookPrice;
    }

    public String getBookType() {
        return bookType;
    }

    public void setBookType(String bookType) {
        this.bookType = bookType;
    }

    public String getBookFromLocation() {
        return bookFromLocation;
    }

    public void setBookFromLocation(String bookFromLocation) {
        this.bookFromLocation = bookFromLocation;
    }

    public String getBookCurrentLocation() {
        return bookCurrentLocation;
    }

    public void setBookCurrentLocation(String bookCurrentLocation) {
        this.bookCurrentLocation = bookCurrentLocation;
    }

    public String getBookStatus() {
        return bookStatus;
    }

    public void setBookStatus(String bookStatus) {
        this.bookStatus = bookStatus;
    }

    public String getPublisher() {
        return publisher;
    }

    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }

    public String getTagId() {
        return tagId;
    }

    public void setTagId(String tagId) {
        this.tagId = tagId;
    }

    public String getBorrowDate() {
        return borrowDate;
    }

    public void setBorrowDate(String borrowDate) {
        this.borrowDate = borrowDate;
    }

    public String getLimitDate() {
        return limitDate;
    }

    public void setLimitDate(String limitDate) {
        this.limitDate = limitDate;
    }

    public boolean isOverdue() {
        return overdue;
    }

    public void setOverdue(boolean overdue) {
        this.overdue = overdue;
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if (obj != null && obj instanceof BookBean) {
            BookBean bean = (BookBean) obj;
            return twoEquels(tagId, bean.getTagId()) || twoEquels(bookId, bean.getBookId());
        }
        return super.equals(obj);
    }

    private boolean twoEquels(String one, String two) {
        if (one != null && two != null) {
            return one.equals(two);
        }
        return false;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean borrowSuccess) {
        this.success = borrowSuccess;
    }

    public String getHintMessage() {
        return hintMessage;
    }

    public void setHintMessage(String hintMessage) {
        this.hintMessage = hintMessage;
    }

    @Override
    public String toString() {
        return "BookBean{" +
                "tagId='" + tagId + '\'' +
                ", bookId='" + bookId + '\'' +
                ", bookName='" + bookName + '\'' +
                ", indexNo='" + indexNo + '\'' +
                ", bookPrice='" + bookPrice + '\'' +
                ", bookType='" + bookType + '\'' +
                ", bookFromLocation='" + bookFromLocation + '\'' +
                ", bookCurrentLocation='" + bookCurrentLocation + '\'' +
                ", bookStatus='" + bookStatus + '\'' +
                ", publisher='" + publisher + '\'' +
                ", author='" + author + '\'' +
                ", borrowDate='" + borrowDate + '\'' +
                ", limitDate='" + limitDate + '\'' +
                ", overdue=" + overdue +
                ", borrowSuccess=" + success +
                ", hintMessage='" + hintMessage + '\'' +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.tagId);
        dest.writeString(this.bookId);
        dest.writeString(this.bookName);
        dest.writeString(this.indexNo);
        dest.writeString(this.bookPrice);
        dest.writeString(this.bookType);
        dest.writeString(this.bookFromLocation);
        dest.writeString(this.bookCurrentLocation);
        dest.writeString(this.bookStatus);
        dest.writeString(this.publisher);
        dest.writeString(this.author);
        dest.writeString(this.borrowDate);
        dest.writeString(this.limitDate);
        dest.writeByte(this.overdue ? (byte) 1 : (byte) 0);
        dest.writeByte(this.success ? (byte) 1 : (byte) 0);
        dest.writeString(this.hintMessage);
    }

    public BookBean() {
    }

    protected BookBean(Parcel in) {
        this.tagId = in.readString();
        this.bookId = in.readString();
        this.bookName = in.readString();
        this.indexNo = in.readString();
        this.bookPrice = in.readString();
        this.bookType = in.readString();
        this.bookFromLocation = in.readString();
        this.bookCurrentLocation = in.readString();
        this.bookStatus = in.readString();
        this.publisher = in.readString();
        this.author = in.readString();
        this.borrowDate = in.readString();
        this.limitDate = in.readString();
        this.overdue = in.readByte() != 0;
        this.success = in.readByte() != 0;
        this.hintMessage = in.readString();
    }

    public static final Parcelable.Creator<BookBean> CREATOR = new Parcelable.Creator<BookBean>() {
        @Override
        public BookBean createFromParcel(Parcel source) {
            return new BookBean(source);
        }

        @Override
        public BookBean[] newArray(int size) {
            return new BookBean[size];
        }
    };
}
